package com.function.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.function.domin.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * 将申请人插入临时用户表
     * @param user
     */
    @Insert("insert into temp_user (username, password, email_account, create_time, update_time) " +
            "VALUES (#{username}, #{password}, #{emailAccount}, #{createTime}, #{updateTime})")
    void insertTempUser(User user);

    /**
     *  找到最新加入临时用户表的用户
     */
    @Select("select * from temp_user order by create_time desc limit 1")
    User selectLastTempUser();

    /**
     * 用户注册成功后更新TempUser表
     * @param user
     */
    @Update("update temp_user set update_time = #{updateTime} where username = #{username}")
    void updateTempUser(User user);
}
